package funjava;

import java.util.Arrays;
import java.util.Comparator;

/**
 * Created by judasnow on 5/26/16.
 */

class LengthComparator implements Comparator<String> {
    @Override
    public int compare(String first, String second) {
        return first.length() - second.length();
    }
}

public class C4_test_1 {
    public static void main(String[] args) {
        String[] friends = {"vincent", "judasnow", "sonw", "a"};
        Arrays.sort(friends, new LengthComparator());

        for (String s: friends) {
            System.out.println(s);
        }
    }
}
